//
// Created by Administrator on 2023/7/28.
//
#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    vector<vector<int>> largestLocal(vector<vector<int>> &grid) {
        int n = grid.size();
        vector<vector<int>> ans(n - 2, vector<int>(n - 2, 0));
        for (int i = 0; i < n - 2; ++i) {
            for (int j = 0; j < n - 2; ++j) {
                for (int x = i; x < i + 3; ++x) {
                    for (int y = j; y < j + 3; ++y) {
                        ans[i][j] = max(ans[i][j], grid[x][y]);
                    }
                }
            }
        }
        return ans;
    }
};

int main() {
    Solution s;
    vector<vector<int>> grid{{9, 9, 8, 1},
                             {5, 6, 2, 6},
                             {8, 2, 6, 4},
                             {6, 2, 2, 2}};
    auto ans = s.largestLocal(grid);
    for (auto &row: ans) {
        for (auto &x: row) {
            cout << x << endl;
        }
    }
}
